1. Field of the Invention
The present invention relates to computer graphics systems and, more particularly to a system and method for reducing the effects of aliasing in a computer graphics system.
2. Discussion of the Related Art
Computer graphics systems are commonly used for displaying graphical representations of objects on a two-dimensional video display screen. Current computer graphics display systems provide highly detailed representations and are used in a variety of applications. A computer graphics display system generally comprises a central processing unit (CPU), system memory, a graphics machine and a video display screen.
In typical computer graphics display systems, an object to be presented on the display screen is broken down into graphics primitives. Primitives are basic components of a graphics display and may include points, lines, and polygons (e.g., triangles and quadrilaterals). Typically, a hardware/software scheme is implemented to render, or draw, the graphics primitives that represent a view of one or more objects being represented on the display screen.
Generally, the primitives of the three-dimensional object to be rendered are defined by the host CPU in terms of primitive data. For example, when the primitive is a triangle, the host computer may define the primitive in terms of the X, Y and Z coordinates of its vertices, as well as in terms of the red, green, blue and alpha (R, G, B and xcex1) color values of each vertex. Alpha is a transparency value. Additional primitive data may be used in specific applications. Rendering hardware interpolates the primitive data to compute the display screen pixels that represent each primitive, and the R, G, B and xcex1 values for each pixel.
In the scan conversion process of a primitive or polygon, the polygon which is defined by the coordinates of its vertices, is converted to a raster image. The outline or edges of the polygon are first determined and the pixels between the polygon edges are then filled. The vertices of the polygon are translated into the display coordinate space and a line scan conversion algorithm is used,to determine the lines between vertices, which form the edges of the polygon. The line scan conversion algorithm computes the coordinates of the pixels, which lie closest to the line between vertices on a two-dimensional raster grid. However, the lines do not always coincide or xe2x80x9cline upxe2x80x9d with pixel locations. Although the closest pixel is chosen, the resulting line contains the undesirable alias effect. This undesirable effect also is carried into the polygon rendering process.
To better illustrate the phenomenon of aliasing and anti-aliasing correction (anti-aliasing), reference is made to FIGS. 1A through 1D. By way of a relatively simple illustration, FIG. 1A shows two cubes 10 and 12, which are leaned against one another. Specifically, cube 12 is leaned against cube 10 in a manner that partially obstructs the view of cube 10. Although not specifically illustrated in the drawing, further assume that the two cubes 10 and 12 have distinct and different colors. For example, cube 10 may be red, while cube 12 may be blue. The drawing of FIG. 1A shows crisp, straight lines for the edges of the cubes. However, and as should be understood, due to the problem of aliasing, the edges of the cubes (the edges where the cubes overlap) may become jagged.
To more particularly illustrate, reference is made to FIG. 1B, which illustrates that portion of FIG. 1A denoted by dashed line (reference numeral 14). In this regard, FIG. 1B shows a line 16, which is the true edge of cube 12. Surrounding this edge 16 are an array of pixels. Each pixel is represented with a center point, and an outer, circular rim. As illustrated, a number of pixels (illustrated in dashed line) have at least some portion that intersects the edge 16. These are also referred to as edge pixels. The remaining pixels will be assigned a solid color, corresponding to the color of the respective cube. In keeping with the previous example, pixels containing the letter B are assigned a blue color, while pixels containing the letter R are assigned a red color. With regard to the remaining pixels, if no anti-aliasing measures are employed, then the pixel colors are assigned to the color of the primitive containing the center point of the pixel. Under this approach, the pixels containing the letters BE (for blue edge) are also assigned the color blue, while pixels containing the letters RE (for red edge) are assigned a color red.
To better appreciate how this image may appear, reference is made to FIG. 1C, which illustrates the red pixels with black circles, and the blue pixels with white circles. It can be readily seen that the edge 16 is not crisply defined by the pixels, but rather a jagged edge, or appearance, results. When anti-aliasing measures are employed, however, the jagged appearance of this edge is smoothed over. This smoothing process is carried out by blending the color of adjacent pixels, in accordance to the relative proportion of the color within the pixel. For example, and again referring to FIG. 1B, pixel 18 is predominantly located within the red cube, having only a small portion located within the blue cube. Likewise, pixel 20 is located predominantly within the blue cube, having only a small portion located within the red cube. Pixel 22 is located substantially half-and-half between the red cube and the blue cube. With antialiasing measures employed, each of these edge pixels will be assigned some shade of purple or maroon (i.e., a blending of red and blue), depending upon the relative proportion of the colors within each pixel. Therefore, pixel 18 will be predominantly red, pixel 20 will be prominently blue, and pixel 22 will be a relatively even mix of red and blue. This blending operation is illustrated in black and white, by using shades of gray. As illustrated in FIG. 1D, pixel 18 is a slightly darker shade of gray than pixel 22, which in turn is slightly darker than pixel 20. Overall, this blending of colors serves to smoothing the appearance of the otherwise jagged edge between cubes 10 and 12.
Anti-aliasing methods are generally classified into a super-sampling method and an area sampling method. In the super-sampling method, the color value of a pixel is calculated by obtaining the color values of several sub-pixels within the pixel and averaging (or blending) the obtained color values of the sub-pixels. In area sampling, the area of the polygon occupying a pixel is calculated and then the color value of the area ratio is calculated. However this approach requires additional memory, and more extensive computations.
Other methods have also been proposed, which perform a blending of colors by computing a percentage of a given pixel covered by a first color, versus a second color (across a primitive edge).
OpenGL is known to provide a polygon anti-aliasing feature (called Polygon_Smooth). However, it requires a back to front (depth-wise) ordering of the primitives within the graphic scene to be rendered. This is often extremely difficult to ensure, and at the very least increases the complexity imposed upon the application designer.
Accordingly, it is desired to provide a system and method that provide an improved solution to effectively address the problem of aliasing in a computer graphics system.
Certain objects, advantages and novel features of the invention will be set forth in part in the description that follows and in part will become apparent to those skilled in the art upon examination of the following or may be learned with the practice of the invention. The objects and advantages of the invention may be realized and obtained by means of the instrumentalities and combinations particularly pointed out in the appended claims.
To achieve the advantages and novel features, the present invention is generally directed to a system and method for anti-aliasing edges of adjacent primitives. In accordance with one aspect of the invention, a method operates by determining whether a pixel is an edge pixel of a filled primitive, approximating a coverage area of the pixel, the coverage area being the area of the pixel interior to the primitive edge, determining a direction from the pixel center to an external edge of the primitive, and blending a first color of the primitive with a second color, the second color being a color of a pixel of a second primitive adjacent the external edge.
In accordance with a related aspect of the invention, a method operates by evaluating a pixel to determine whether the pixel is on the edge of a filled primitive, determining a coverage area of the pixel, determining a direction from the pixel center to an external edge of the primitive, and blending a first color of the primitive with a second color, the second color being a color of a second primitive adjacent the pixel and in the determined direction.
In accordance with another aspect of the invention, a system is provided having frame buffer circuitry uniquely configured for rendering an anti-aliased graphics scene. In accordance with one embodiment, the frame buffer circuitry includes a first memory segment for storing color values associated with pixels, a second memory segment for storing alpha values associated with the pixels, a third memory segment for storing depth values associated with the pixels, and a fourth memory segment for storing anti-alias blending information associated with the pixels.
In a conventional rasterization process, only the pixels having centerpoints within a primitive are covered by the primitive, and therefore rendered (see FIG. 1C). However, and in accordance with present invention, the region of interest is effectively extended to pixels that touch the primitive edge in any amount. This allows the invention to represent minority coverage of a pixel by an appropriate blending by a coverage percentage.
One method of representing the primitive coverage of pixels with less than a 50% coverage value (e.g. the centerpoint is not covered) is to not modify the color buffer for this pixel, but rather only modify anti-alias (A/A) blend information to point toward the adjacent pixel having a centerpoint that is covered by the current primitive. This allows the minority contribution of this primitive to be considered while preserving original color value that represents the majority of this pixel""s cover.